package m.store.model;

import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name="ts_store_goods_history",description="商户商品历史")
public class StoreGoodsHistory extends Model implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("goods.store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="goods_oid",table= StoreGoods.class,description="商户商品")
    private StoreGoods goods;
    @FieldMeta(name="type_name",type= FieldType.STRING,length=100,description="商品类型")
    private String typeName;
    @FieldMeta(name="factoryName",type= FieldType.STRING,length=100,description="厂商名称")
    private String factoryName;
    @FieldMeta(name="name",type= FieldType.STRING,length=300,description="商品名称")
    private String name;
    @FieldMeta(name="attr_json",type= FieldType.STRING,dbType = "text",description="属性json")
    private String attrJson;
    @FieldMeta(name="end_date",type= FieldType.DATE,description="结束时间")
    private Date endDate;

    public StoreGoods getGoods() {
        return goods;
    }

    public void setGoods(StoreGoods goods) {
        this.goods = goods;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getFactoryName() {
        return factoryName;
    }

    public void setFactoryName(String factoryName) {
        this.factoryName = factoryName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAttrJson() {
        return attrJson;
    }

    public void setAttrJson(String attrJson) {
        this.attrJson = attrJson;
    }

}
